//
//  fun_boxViewController.m
//  fun box
//
//  Created by Will Martin on 10/4/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "fun_boxViewController.h"

@implementation fun_boxViewController

-(IBAction)slideOne: (UISlider *) sender{
	twoSlider.value = (oneSlider.value)*-1;
	leftSlider.value = (oneSlider.value)*1;
	rightSlider.value = (oneSlider.value)*-1;
}

-(IBAction)slideTwo: (UISlider *) sender{
	oneSlider.value = (twoSlider.value)*-1;
	leftSlider.value = (twoSlider.value)*-1;
	rightSlider.value = (twoSlider.value)*1;
}

-(IBAction)slideLeft: (UISlider *) sender{
	oneSlider.value = (leftSlider.value)*1;
	twoSlider.value = (leftSlider.value)*-1;
	rightSlider.value = (leftSlider.value)*-1;
}

-(IBAction)slideRight: (UISlider *) sender{
	oneSlider.value = (rightSlider.value)*-1;
	twoSlider.value = (rightSlider.value)* 1;
	leftSlider.value = (rightSlider.value)*-1;
}


-(IBAction)buttonPressed: (UIButton *) sender{
	if(![keyboardLock isOn]){
		NSString *symbol = [[sender titleLabel] text];
		if(userIsInTheMiddleOfTyping){
			[display setText:[[display text] stringByAppendingString:symbol]];
		}
		else {
			[display setText:symbol];
			userIsInTheMiddleOfTyping = YES;
		}
	}
}

-(IBAction)insertSpace: (UIButton *) sender{
	if(![keyboardLock isOn]){
		[display setText:[[display text] stringByAppendingString:@" "]];
	}
}

-(IBAction)clear: (UIButton *) sender{
	if(![keyboardLock isOn]){
		[display setText:@""];
		userIsInTheMiddleOfTyping = NO;
	}
}

-(IBAction)enter: (UIButton *) sender{
	if(![keyboardLock isOn]){
	NSString *symbol = [display text];
	if ([symbol isEqualToString:@"I HATE MY LIFE"]) {
		[display setText:@"ME TOO"];
	}
	else if ([symbol isEqualToString:@"WHAT IS THE ANSWER"]) {
		[display setText:@"42"];
	}
	else if ([symbol isEqualToString:@"WHO IS THE CS GOD"]) {
		[display setText:@"ANDY"];
	}
	else if([symbol isEqualToString:@"SET COLOR"]) {
		colorChanging = YES;
		[display setText:@"WHAT COLOR TO CHANGE THE BACKGROUND TO"];
		userIsInTheMiddleOfTyping = NO;
	}
	else if([symbol isEqualToString:@"LIST COLORS"]){
		[display setText:@"WHITE, BLACK, RED, BROWN, GREY, GREEN"];
		userIsInTheMiddleOfTyping = NO;
	}
	else if([symbol isEqualToString:@"WHY THE SLIDERS"]){
		[display setText:@"ITS FOR THE KIDS"];
		userIsInTheMiddleOfTyping = NO;
	}
	else if([symbol isEqualToString:@"HELP"]){
		[display setText:@"LIST OF AVAILABLE COMMANDS: 'I HATE MY LIFE' 'WHAT IS THE ANSWER' 'WHO IS THE CS GOD' 'LIST COLORS' 'SET COLOR' 'HELP' 'WHY THE SLIDERS'"];
		userIsInTheMiddleOfTyping = NO;
	}
	else {
		[display setText:@"UNRECOGNIZED COMMAND  TYPE HELP FOR ASSISTANCE"];
		userIsInTheMiddleOfTyping = NO;
	}
	/*else if([symbol isEqualToString:@"DO YOU HAVE HALLOWEEN MODE"]){
		[display setText:@"NO I HATE HALLOWEEN"];
		userIsInTheMiddleOfTyping = NO;
	}
	else if([symbol isEqualToString:@"WHY IS THERE NO HALLOWEEN MODE"]){
		[display setText:@"DO I LOOK LIKE IM FIVE"];
		userIsInTheMiddleOfTyping = NO;
	}*/
	
	if(colorChanging) {
		if([symbol isEqualToString:@"WHITE"]){
			[self.view setBackgroundColor:[UIColor whiteColor]];
			colorChanging = NO;
			[display setText:@"BACKGROUND COLOR IS NOW WHITE"];
			userIsInTheMiddleOfTyping = NO;
		}
		else if([symbol isEqualToString:@"BLACK"]){
			[self.view setBackgroundColor:[UIColor blackColor]];
			colorChanging = NO;
			[display setText:@"BACKGROUND COLOR IS NOW BLACK"];
			userIsInTheMiddleOfTyping = NO;
		}
		else if([symbol isEqualToString:@"RED"]){
			[self.view setBackgroundColor:[UIColor redColor]];
			colorChanging = NO;
			[display setText:@"BACKGROUND COLOR IS NOW RED"];
			userIsInTheMiddleOfTyping = NO;
		}
		else if([symbol isEqualToString:@"BROWN"]){
			[self.view setBackgroundColor:[UIColor brownColor]];
			colorChanging = NO;
			[display setText:@"BACKGROUND COLOR IS NOW BROWN"];
			userIsInTheMiddleOfTyping = NO;
		}
		else if([symbol isEqualToString:@"GREY"]){
			[self.view setBackgroundColor:[UIColor lightGrayColor]];
			colorChanging = NO;
			[display setText:@"BACKGROUND COLOR IS NOW GREY"];
			userIsInTheMiddleOfTyping = NO;
		}
		else if([symbol isEqualToString:@"GREEN"]){
			[self.view setBackgroundColor:[UIColor greenColor]];
			colorChanging = NO;
			[display setText:@"BACKGROUND COLOR IS NOW GREEN"];
			userIsInTheMiddleOfTyping = NO;
		}
	}
		
	
	
	userIsInTheMiddleOfTyping = NO;
	}
}

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	colorChanging = NO;
	[display setText:@"HELLO WORLD"];
	leftSlider.transform = CGAffineTransformRotate(leftSlider.transform, 270.0/180*M_PI);
	rightSlider.transform = CGAffineTransformRotate(rightSlider.transform, 270.0/180*M_PI);
	
}



// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
